﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>呷饭网</title>
    <link rel="stylesheet" type="text/css" href="./styles/mobile.css" />
    <link href="styles/jquery.ui.all.css" rel="stylesheet" />
    <script type="text/javascript" src="scripts/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="scripts/jquery.bgiframe-2.1.1.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.core.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.widget.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.mouse.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.button.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.draggable.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.position.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.dialog.js"></script>
    <link href="styles/flexy-menu.css" rel="stylesheet" />
    <script type="text/javascript" src="scripts/flexy-menu.js"></script>
    <script type="text/javascript" src="scripts/common.js"></script>

    <script type="text/javascript">
        $(document).ready(function () {
            $(".flexy-menu").flexymenu({ speed: 100 });
            $('.goback').click(function () {
                window.history.back();
            });
        });

        var OrderId;
        var HotelId;

        $(function () {
            OrderId = getParameter("OrderId");
            HotelId = getParameter("HotelId");
            getUserInfo();
            getListData(OrderId);
        });

        function getListData(OrderId)
        {
            getOrderDetail(OrderId);
        }

        //获取未就坐订单和订单菜单信息
        function getOrderDetail(OrderId) {
            $("#tbllist").html("");
            var datas = "&OrderId=" + OrderId;
            var url = "CommonPage.aspx?opration=getOrderDetail" + datas;
            $.ajax({
                url: url,
                type: "post",
                dataType: 'json',
                success: function (data) {
                    if (data.Success) {
                        $("#query-tips")[0].style.display = "none";
                        $("#ContactUser").text(data.ContactUser);
                        $("#Dinecondition").text(data.Name + "(" + data.PeopleNum + "人桌)");
                        $("#ContactMobile").text(data.ContactMobile);
                        if (data.DineNum == 0) {
                            $("#DineNum").text("未定");
                        }
                        else {
                            $("#DineNum").text(data.DineNum);
                        }
                        $("#hide_DineTable").val(data.DineTable);
                        $("#BookedDate").text(data.BookedDate);
                        $("#RetentionTime").text(data.RetentionTime+"分钟");
                        $("#Numbers").text(data.Numbers);
                        $("#Prices").text(data.Prices);
                        
                        if (data.IsShow == 1) {
                            $("#tabShow")[0].style.display = "";
                            $("#tabDisabled")[0].style.display = "none";
                            $("#tbCancel")[0].style.display = "none";
                        }
                        else {
                            $("#tabShow")[0].style.display = "none";
                            $("#tabDisabled")[0].style.display = "";
                            $("#tbCancel")[0].style.display = "";
                        }
                        if (data.Numbers == "0") {
                            $("#query-tips")[0].style.display = "";
                            $("#querytips").text(data.Msg);
                        }
                        else {
                            for (var i = 0, str = ''; i < data.List.length; i++) {
                                str += "<tr><td class='l'>" + data.List[i].CName + "</td><td class='c'>￥" + data.List[i].Price + "</td><td class='r'>" + data.List[i].Num + "份</td></tr>";
                            }
                        }
                        $("#tbllist").html(str);
                    }
                    else {
                        if (data.Url != "") {
                            updateTip(data.Msg, true, "URL", data.Url);
                        }
                        else {
                            $("#query-tips")[0].style.display = "";
                            $("#querytips").text(data.Msg);
                        }
                    }
                }
            });
        }

        //订单就坐
        function updateOrderState() {
            var DineNum = $("#DineNum").text();
            if (DineNum == "未定") {
                DineNum = "0";
            }
            var html = "确认人数：<input type='text' id=jcrs value='" + DineNum + "' />";
            $(".dialogTip").html(html);
            $("#dialog").dialog({
                resizable: false,
                height: 130,
                modal: true,
                position: ["center", "center"],
                buttons: {
                    "关 闭": function () {
                        $(this).dialog("close");
                    },
                    "确 定": function () {
                        var jcrs = $("#jcrs").val();
                        if ($("#jcrs").val() == "") {
                            alert("请输入就餐人数");
                            $("#jcrs").focus();
                            return false;
                        } 
                        var datas = "&HotelId=" + HotelId + "&OrderId=" + OrderId;
                        var url = "CommonPage.aspx?opration=updateOrderState" + datas + "&jcrs=" + jcrs;
                        $.ajax({
                            url: url,
                            type: "post",
                            dataType: 'json',
                            success: function (data) {
                                if (data.Success) {
                                    var str = data.Url + "?PageFlag=1&HotelId=" + HotelId + "&OrderId=" + OrderId;
                                    //updateTip(data.Msg, true, "URL", str);
                                    document.location.href = str;
                                }
                                else {
                                    updateTip(data.Msg, false, "", "");
                                }
                            }
                        });
                    }
                }
            });  
        }

        //订单延时
        function updateOrderBookedDate() {
            var BookedDate = $("#BookedDate")[0].innerText;
            var RetentionTime = $("#RetentionTime")[0].innerText.replace("分钟","");
            var datas = "&OrderId=" + OrderId + "&BookedDate=" + BookedDate + "&RetentionTime=" + RetentionTime;
            var url = "CommonPage.aspx?opration=updateOrderBookedDate" + datas;
            $.ajax({
                url: url,
                type: "post",
                dataType: 'json',
                success: function (data) {
                    if (data.Success) {
                        updateTip(data.Msg, true, "Method", OrderId);
                    }
                    else {
                        updateTip(data.Msg, false, "", "");
                    }
                }
            });
        }

        //取消订单
        function cancelDineTable() {
            $(".dialogTip").text("是否取消订单？")
            $("#dialog").dialog({
                resizable: false,
                height: 120,
                modal: true,
                position: ["center", "center"],
                buttons: {
                    "关 闭": function () {
                        $(this).dialog("close");
                    },
                    "确 定": function () {
                        var datas = "&HotelId=" + HotelId + "&OrderId=" + OrderId;
                        var url = "CommonPage.aspx?opration=cancelDineTable" + datas;
                        $.ajax({
                            url: url,
                            type: "post",
                            dataType: 'json',
                            success: function (data) {
                                $(this).dialog("close");
                                if (data.Success) {
                                    //updateTip(data.Msg, true, "URL", data.Url);
                                    document.location.href = data.Url;
                                }
                                else {
                                    updateTip(data.Msg, false, "", "");
                                }
                            }
                        });
                    }
                }
            });
        }
    </script>
</head>

<body>
    <div class="wrapall">
        <table class="topbar">
            <tr>
                <td class="l"><a class="goback">返回</a></td>
                <td class="c" id="H_Name"></td>
                <td class="r" align="right">
                    <ul class="flexy-menu">
                        <li id="lilist">
                        </li>
                    </ul>
                </td>
            </tr>
        </table>
        <p class="textinfo"><b id="ContactUser"></b>预定</p>
        <table class="tblhd">
            <tr>
                <td class="l" id="Dinecondition"></td>
                <td class="c"></td>
                <td style="width:30%;">
                    <table style="width:100%;display:none;" id="tbCancel">
                        <tr>
                            <td align="right" style="text-align:center;border-top:0px solid #09F; background-color:#09F;font-family:'微软雅黑', '黑体';font-size:13px;padding:8px 10px;"><a href="#" onclick="cancelDineTable();" style="color:white;">取消订单</a></td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <table class="tblbd">
            <tr>
                <th>电话</th>
                <td id="ContactMobile"></td>
            </tr>
            <tr>
                <th>人数</th>
                <td id="DineNum"></td>
            </tr>
            <tr>
                <th>就餐时间</th>
                <td id="BookedDate"></td>
            </tr>
            <tr>
                <th>保留时间</th>
                <td id="RetentionTime"></td>
            </tr>
        </table>
        <table class="tblbtn">
            <tr>
                <td style="display:none;padding:5px 8px;" id="tabShow"><a href="#" onclick="updateOrderState();">就坐</a></td>
                <td style="display:none;padding:5px 8px;" id="tabDisabled"><a href="#" style="background-color:darkgray;cursor:default;">就坐</a></td>
                <td style="padding:5px 8px;"><a href="#" onclick="updateOrderBookedDate();">延时</a></td>
                <td style="padding:5px 8px;"><a href="#" onclick="showDineTable();">换桌</a></td>
                <!--<td id="tbCancel" style="display:none;padding:5px 8px;"><a href="#" onclick="cancelDineTable();">取消</a></td>-->
            </tr>
        </table>
        <table class="tblhd">
            <tr>
                <td class="l">菜单</td>
                <td class="c"></td>
                <td class="r">（共<b id="Numbers">0</b>份，金额<b id="Prices">0</b>元）</td>
            </tr>
        </table>
        <table class="tbllist" id="tbllist">
        </table>
        <span class="tips" id="query-tips" style="display:none;"><i></i><b id="querytips"></b>

        </span>
        <br />
    </div>
    <div id="dialog" title="提示信息" style="text-align:center; vertical-align: middle;">
        <p class="dialogTip"></p>
    </div>
    <div id="DineTable" title="可换桌位">
        <table class="tbllist" id="tblDineTable">
        </table>
    </div>
    <input type="hidden" id="hide_DineTable" value="" />
</body>
</html>
